package com.lichuandi.crawler;

import org.apache.http.HttpEntity;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class SichuanAirHttpClient {

    public void httpClientLogin(String loginUrl, String userInfoUrl) throws Exception {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        HttpUriRequest login = RequestBuilder.post().setUri(loginUrl)
                .setHeader("", "")
                .setHeader("", "")
                .setHeader("", "")
                .addParameter("name", "")
                .addParameter("", "")
                .addParameter("", "")
                .addParameter("", "")
                .build();
        // 模拟登录
        CloseableHttpResponse response = httpClient.execute(login);
        if (response.getStatusLine().getStatusCode() == 200) {
            HttpGet httpGet = new HttpGet(userInfoUrl);
            CloseableHttpResponse userResponse = httpClient.execute(httpGet);
            HttpEntity entity = userResponse.getEntity();
            String body = EntityUtils.toString(entity, "utf-8");


        } else {
            System.out.println("模拟登录失败");
        }

    }
}

